import java.io.File;
import java.math.BigDecimal;
import java.text.DecimalFormat;

public class StringTest {
	public static String msg="1234%s5";
	public static void main(String[] args) {
		StringBuffer buf = new StringBuffer(msg);
		buf.replace(2, 3, "4");
		System.out.println(msg);
		System.out.println(buf);
		System.out.println(String.format(msg, "test"));
		msg = msg + ",";
		System.out.println(msg);
		DecimalFormat df1 = new DecimalFormat("0.00");  
		BigDecimal amt = new BigDecimal(0.10);
		System.out.println(changeY2F(df1.format(amt)));
		
		System.out.println(df1.format(amt).replace(".", ""));
		
		String type=null;
		if("2".equals(type)) {
			System.out.println("2222");
		}
		String date = "2018-10-22";
		System.out.println(date.replace("-", ""));
		System.out.println(System.getProperty("file.encoding"));
		
		File file = new File("/stdcop/stdepcc/midltest/depPrint01_21130002_2222_2222_2223.dat");
		System.out.println(file.getName());
		System.out.println(file.getParent());
		
		String tmp = "sfsf ssf ";
		System.out.println(tmp.replaceAll(" ", ""));
		String allstring = "234324|20000|100000|";
		String txcode = "11103";
		StringBuilder build = new StringBuilder(txcode);
		build.replace(2, 3, "2");
		System.out.println(build.toString());
	}
	  /**  
     * 将元为单位的转换为分 替换小数点，支持以逗号区分的金额 
     *  
     * @param amount 
     * @return 
     */  
    public static String changeY2F(String amount){  
        String currency =  amount.replaceAll("\\$|\\￥|\\,", "");  //处理包含, ￥ 或者$的金额  
        int index = currency.indexOf(".");  
        int length = currency.length();  
        Long amLong = 0l;  
        if(index == -1){  
            amLong = Long.valueOf(currency+"00");  
        }else if(length - index >= 3){  
            amLong = Long.valueOf((currency.substring(0, index+3)).replace(".", ""));  
        }else if(length - index == 2){  
            amLong = Long.valueOf((currency.substring(0, index+2)).replace(".", "")+0);  
        }else{  
            amLong = Long.valueOf((currency.substring(0, index+1)).replace(".", "")+"00");  
        }  
        return amLong.toString();  
    }  

}
